#!/bin/bash

# if [条件];then
#     elif [条件];then
#     elif [条件];then
#     else
# fi

# install_path="/usr/local/"
# if [ -d ${install_path}/apache ];then
#     echo  "有此目录"
# else
#     mkdir ${install_path}/apache
#     echo "没有此目录"
# fi


#example:  
# 1. 检查local_repo.tar 
# 2. 构建备份文件
# 3. 移动到目标目录中
# 4. 否则退出


# if [ -f   /etc/yum.repos.d/local_repo.tar ];then
#     echo  "没有"
# elif [ -d  /etc/yum.repos.d/bak ];then
#     echo  "有"
# else
#     echo  "不好意思没有"
# fi 
repo_path="/etc/yum.repos.d"
dest_path="/opt"
if [ -f  ${repo_path}/local_repo.tar ];then
    #scp 推送到备份节点上 rsync
    mv ${repo_path}/local_repo.tar  $dest_path 
elif [ -d  ${repo_path}/bak ];then
    tar  -cf  repo_bak.tar ${repo_path}/bak
    if [ $?  -eq  0 ];then
    mv repo_bak.tar  ${dest_path}  
    else
    echo "脚本执行未完成"
    fi
else
    tar  -cf  /opt/local_repo.tar  /etc/yum.repos.d/local.repo 
    if [ $?  -eq 0 ];then
     ls /opt/
    fi 
fi 
